package cn.gok;

import cn.gok.dao.UserDAO;
import cn.gok.entity.User;
import cn.gok.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @Author: chen fan
 * @Date: 2022年10月31日 17:42:39
 */

public class UserService {
    public Map<String, String> login(User user){
        SqlSession sqlSession = MybatisUtil.getSQLSession();
        UserDAO userDAO = sqlSession.getMapper(UserDAO.class);
        User userx = userDAO.findUserByUserNameAndPassword(user);

        Map<String, String> result = new HashMap<>();

        if (userx == null){
            result.put("msg","用户名或密码错误，登录失败");
            return result;
        }

        result.put("msg","登录成功");
        return result;
    }
}
